package com.herui.iot.ui.view.ecg.bean;


import com.herui.sport_care.config.ECGConfig;

/**
 * Created by amanda.shan on 2017/1/13.
 */

public enum EcgShowType {
    _1x12, _2x6, _4x3;

    public static WavePos getWavePos(EcgShowType ecgShowType, int leadFalg, int w, int h) {

        switch (ecgShowType) {
            case _1x12:
                return get_1x12_Point(leadFalg, w, h);
            case _2x6:
                return get_2x6_Point(leadFalg, w, h);
            case _4x3:
                return get_4x3_Point(leadFalg, w, h);
        }
        return null;
    }

    public static WavePos get_1x12_Point(int leadFalg, int w, int h) {
        int wLeadView = w;
        int hLeadView = h / ECGConfig.ECGLEADNAMES.size();

        Point lTop = new Point(0, hLeadView * leadFalg); // 左上
        Point lBot = new Point(0, hLeadView * (leadFalg + 1)); // 左下
        Point rTop = new Point(wLeadView, hLeadView * leadFalg); // 右上
        Point rBot = new Point(wLeadView, hLeadView * (leadFalg + 1)); // 右下

        WavePos wavePos = new WavePos();
        wavePos.setlBot(lBot);
        wavePos.setlTop(lTop);
        wavePos.setrBot(rBot);
        wavePos.setrTop(rTop);

        return wavePos;
    }

    public static WavePos get_2x6_Point(int leadFalg, int w, int h) {
        int startX;

        if (leadFalg / 6 == 0)
            startX = 0;
        else
            startX = w / 2;

        int hLeadView = h / 6;

        Point lTop = new Point(startX, hLeadView * (leadFalg % 6)); // 左上
        Point lBot = new Point(startX, hLeadView * (leadFalg % 6 + 1)); // 左下
        Point rTop = new Point(startX + w / 2, hLeadView * (leadFalg % 6)); // 右上
        Point rBot = new Point(startX + w / 2, hLeadView * (leadFalg % 6 + 1)); // 右下

        WavePos wavePos = new WavePos();
        wavePos.setlBot(lBot);
        wavePos.setlTop(lTop);
        wavePos.setrBot(rBot);
        wavePos.setrTop(rTop);

        return wavePos;
    }

    public static WavePos get_4x3_Point(int leadFalg, int w, int h) {
        int startX;
        Point lTop = null;
        Point lBot = null;
        Point rTop = null;
        Point rBot = null;

        startX = w / 4 * (leadFalg / 3);
        int hLeadView = h / 4;

        if (leadFalg != -1) {
            lTop = new Point(startX, hLeadView * (leadFalg % 3)); // 左上
            lBot = new Point(startX, hLeadView * (leadFalg % 3 + 1)); // 左下
            rTop = new Point(startX + w / 4, hLeadView * (leadFalg % 3)); // 右上
            rBot = new Point(startX + w / 4, hLeadView * (leadFalg % 3 + 1)); // 右下
        } else {
            lTop = new Point(0, hLeadView * 3); // 左上
            lBot = new Point(0, hLeadView * 4); // 左下
            rTop = new Point(w, hLeadView * 3); // 右上
            rBot = new Point(w, hLeadView * 4); // 右下
        }

        WavePos wavePos = new WavePos();
        wavePos.setlBot(lBot);
        wavePos.setlTop(lTop);
        wavePos.setrBot(rBot);
        wavePos.setrTop(rTop);

        return wavePos;
    }
}
